<?php
class TDGVerAnuncio{
	function getAnuncio($identificadorAnuncio){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT * FROM anuncio WHERE id=$identificadorAnuncio");
		mysql_close($connection);
		return $resultado;
	}
	
	function getFacultad($ident){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT nombre FROM facultad WHERE id=$ident");
		$row = mysql_fetch_row($resultado);
		mysql_close($connection);
		return $row[0];
	}
	
	function getUA($ident){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT nombre FROM UA WHERE id=$ident");
		$row = mysql_fetch_row($resultado);
		mysql_close($connection);
		return $row[0];
	}
	
	function getEncargado($ident){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$resultado = mysql_query("SELECT Nombre, Apellidos FROM cuentasusuarios WHERE ID=$ident");
		$row = mysql_fetch_row($resultado);
		mysql_close($connection);
		return $row[0]." ".$row[1];
	}
	
	function visita($ident){
		session_start();  
		$connection = mysql_connect("mysql.codefactorycr.com","a83527","patito4" );
		$db = mysql_select_db("a83527",$connection);
		$fecha=getdate();
		$fechaVisita=$fecha[year]."/".$fecha[mon]."/".$fecha[mday];

		mysql_query("INSERT INTO visitas VALUES ( '$fechaVisita' , NULL, '$ident',0, '$_SESSION[id]');");
		
		mysql_query("UPDATE anuncio SET Visitas = Visitas+1 WHERE ID=$ident");
		mysql_close($connection);
		return true;
	}
}



?>